package com.mpyy.dao.everyday;

import com.mpyy.pojo.Tree;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @version 1.0
 * @Description ProductTypeDao
 * Author yyjc
 * @Date 2022-03-06 21:22
 */
@Mapper
@Repository
public interface ProductTypeDao {
    @Select("SELECT * FROM product_type WHERE proTypeId=0")
    @Results(value = {
            @Result(property = "id", column = "proTypeId", id = true),
            @Result(property = "title", column = "proTypeName"),
            @Result(property = "children", column = "proTypeId",many = @Many(
                    select = "second"
            ))
    })
    public List<Tree> all();

    @Select("SELECT b.* FROM product_type a,product_type b WHERE a.proTypeId=000 AND b.proLevelParId=000")
    @Results(value = {
            @Result(property = "id",column = "proTypeId",id = true),
            @Result(property = "title",column = "proTypeName"),
            @Result(property = "children",column = "proTypeId",many = @Many(
                    select = "tertiary"
            ))
    })
    public List<Tree> second();
    @Select("SELECT b.* FROM product_type a,product_type b WHERE a.proTypeId=#{proTypeId} AND b.proLevelParId=#{proTypeId}")
    @Results(value = {
            @Result(property = "id",column = "proTypeId",id = true),
            @Result(property = "title",column = "proTypeName")
    })
    public List<Tree> tertiary();
}
